<template>
  <p>登录页</p>
  <div>
    账号: <input type="text" v-model="account" placeholder="请输入你的账号" />
  </div>
  <div>
    密码: <input type="password" v-model="password" placeholder="请输入你的账号" />
  </div>
  <div>
    <button @click="login">登录</button>
  </div>
</template>


<script>
export default {
  data(){
    return {
      account:'',
      password:''
    }
  },
  methods:{
    login(){
      if(this.account === 'admin' && this.password === '123'){
        alert('登录成功')
        const usrInfo = {
          name:'张三',
          phone:'13122223333',
          gender:'男'
        }
        this.$store.commit('updateUserInfo', usrInfo)
        this.$router.push({path:'/user'})
      } else {
        alert('账号密码错误，请重新输入')
      }
    }
  },
}

</script>